<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>附加权限 - Powered By Betou</title>
<meta name="author" content="Betou Team" />
<meta name="copyright" content="Betou" />
<#include "../../head.html"/>
<script type="text/javascript">
$().ready(function() {
	var $inputForm = $("#inputForm");
	var $selectAll = $("#inputForm .selectAll");
	
	 //表单验证
	$inputForm.validate({
		rules: {
			name: "required",
			level:"required digits",
			perms: "required"
		}
	});

	$selectAll.click(function() {
		var $this = $(this);
		var $thisCheckbox = $this.closest("tr").find(":checkbox");
		if ($thisCheckbox.filter(":checked").size() > 0) {
			$thisCheckbox.prop("checked", false);
		} else {
			$thisCheckbox.prop("checked", true);
		}
		return false;
	});

	<#if message??>
		$.message("success", "${message}");
	</#if>
});

var viewRoles=[];


</script>
<style type="text/css">
.authorities label {
	min-width: 100px;
	_width: 100px;
	display: block;
	float: left;
	padding-right: 4px;
	_white-space: nowrap;
}
</style>
</head>
<body class="content">
	<div class="path">
		<a href="../index.jspx">首页</a> &raquo; 附加权限&raquo; ${bean.name!}
	</div>
	<form id="inputForm" action="o_setting_permission.jspx" method="post">
		<input type="hidden" name="id" value="${bean.id!}" />
		<table class="input">
			<tr>
				<th>
					名称:
				</th>
				<td>
					${bean.name!}
				</td>
			</tr>
			<tr>
				<th>描述:</th>
				<td>
					${bean.description!}
				</td>
			</tr>
			<tr>
				<th>&nbsp;</th>
				<td>
					<span class="tips"><span class="green">您当前可操作的最高等级为:1</span></span>
					<ul>
						<li><span class="red">操作等级不起作用的两种情况:</span></li>
						<li>1. 当操作级别为0的</li>
						<li>2. 未选择可操作角色</li>
					</ul>
				</td>
			</tr>
			<#list bean.roleExt as e>
				<tr>
					<th>${e.description!}</th>
					<td>
						操作等级：<input type="text" class="text"  name="${e.key}-findDeep-${e.id}"  value="${e.findDeep!0}" style="width:30px"/>&nbsp;&nbsp;
						<input type="hidden" class="text"  name="${e.key}-updateDeep-${e.id}" value="${e.updateDeep!0}" style="width:30px"/>&nbsp;&nbsp;
						<input type="hidden" class="text"  name="${e.key}-deleteDeep-${e.id}"  value="${e.deleteDeep!0}" style="width:30px"/>
						<a href="javascript:;" class="selectAll" title="全选此组">可操作角色：</a>
						<span class="fieldSet">
							<#list roleList as c>
								<@betou_perm_display system=admin.system identity=c.identity>
								<label><input type="checkbox" name="${e.key}-viewRole-${e.id}" value="${c.id}" />${c.name!}</label> 
								</@betou_perm_display>
							</#list>
						</span>
					</td>
				</tr>
				<script type="text/javascript">
					var x = {"name": "${e.key}-viewRole-${e.id}", "value" : "${e.viewRoles!}"};
					viewRoles.push(x);
				</script>
			</#list>
			<tr>
				<th>&nbsp;</th>
				<td>
					<input type="submit" class="button" value="确&nbsp;&nbsp;定" />
					<input type="button" class="button" value="返&nbsp;&nbsp;回" onclick="location.href='v_list.jspx'" />
				</td>
			</tr>
		</table>
	</form>
	<#include "../../footer.html"/>
</body>
<script type="text/javascript">
	for( var i = 0; i < viewRoles.length; i++ ){
		var viewRole = viewRoles[i];
		var name = viewRole.name;
		var value = viewRole.value;
		if( value != '' ){
			value = value.split(',');
		}

		$("#inputForm input[name=" + name + "]").each(function() {
			var role = $(this).val();
			for(var i=0,len=value.length;i<len;i++) {
				if(value[i]==role) {
					$(this).attr("checked",true);
					break;
				}
			}
		});
	}
</script>
</html>
